package com.af.monitorModule.generator.service.impl;

import com.af.monitorModule.generator.entity.Fragment;
import com.af.monitorModule.generator.entity.InstructionsFragment;
import com.af.monitorModule.generator.mapper.FragmentMapper;
import com.af.monitorModule.generator.mapper.InstructionsFragmentMapper;
import com.af.monitorModule.generator.service.FragmentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lyz_4dou
 * @since 2021-11-15
 */
@Service
public class FragmentServiceImpl extends ServiceImpl<FragmentMapper, Fragment> implements FragmentService {


    @Autowired
    private FragmentMapper fragmentMapper;

    @Autowired
    private InstructionsFragmentMapper instructionsFragmentMapper;

    @Override
    public Fragment getFragmentInfo(String company, String dbName) {
        return fragmentMapper.findNewOne(Integer.parseInt(company), dbName);
    }

    @Override
    public List<InstructionsFragment> getFragmentTaskHistory(String company, String dbName) {
        QueryWrapper<InstructionsFragment> wrapper= new QueryWrapper<InstructionsFragment>().eq("company_id",company).eq("db_name",dbName).orderByDesc("input_date");
        return instructionsFragmentMapper.selectList(wrapper);
    }
}
